home *** CD-ROM | disk | FTP | other *** search
/ Maclife 40 / MACLIFE40.ISO.7z / MACLIFE40.ISO / MACLIFE連載 / 特集II DTPデザインを効率化 / AppleScript⁄サンプル / SampleScript / PhotoShopScript / Auto Action 0.9 / Auto Action.txt < prev    next >
Text File  |  1998-02-10  |  3KB  |  90 lines

  1. on run
  2.     with timeout of 6000 seconds
  3.         set Dolop_List to {}
  4.         tell application "Finder"
  5.             activate
  6.             repeat with sFile in selection
  7.                 set Dolop_List to Dolop_List & (sFile as alias)
  8.             end repeat
  9.             if Dolop_List is {} then display dialog "please select files or folders!!!"
  10.             if (name of item 1 of Dolop_List as string) is "Aoto Action" then
  11.                 set Dolop_List to {}
  12.                 repeat
  13.                     try
  14.                         choose file with prompt "処理するファイルを順に選んでください。"
  15.                         set Dolop_List to Dolop_List & result
  16.                     on error errMsg number ERRNO
  17.                         if ERRNO is -128 then --キャンセルが押されたら
  18.                             exit repeat
  19.                         else --それ以外の不意打ちには
  20.                             error errMsg & ERRNO
  21.                             exit repeat
  22.                         end if
  23.                     end try
  24.                 end repeat
  25.             end if
  26.             display dialog "実行するアクションの名前を入力してください" default answer "名称未設定 1"
  27.             set Action_name to text returned of result
  28.             my Action_G(Action_name, Dolop_List)
  29.         end tell
  30.     end timeout
  31. end run
  32.  
  33.  
  34. on open Dolop_List
  35.     with timeout of 6000 seconds
  36.         tell application "Finder"
  37.         end tell
  38.         display dialog "実行するアクションの名前を入力してください" default answer "名称未設定 1" default button 3
  39.         set Action_name to text returned of result
  40.         my Action_G(Action_name, Dolop_List)
  41.     end timeout
  42. end open
  43.  
  44.  
  45. on Action_G(Action_name, Dolop_List)
  46.     tell application "Finder"
  47.         set File_list to {}
  48.         set File_Type to {"TIFF", "8BPS", "BMP", "EPSF", "JPEG", "PCX", "PDF", "PICT", "SCRN", "PXR", "PNGf", "..CT", "TPIC"} as list
  49.         set AA to 0
  50.         set BB to 0
  51.         repeat with i in Dolop_List
  52.             --try
  53.             if disk (i as string) exists then
  54.                 set Check_disk to every file of entire contents of disk (i as string) --disk中の全てのファイルを再帰的に拾う
  55.                 my Action_G(Action_name, Check_disk)
  56.             else if folder (i as string) exists then
  57.                 set Check_Folder to every file of entire contents of folder (i as string) --folder中の全てのファイルを再帰的に拾う
  58.                 my Action_G(Action_name, Check_Folder)
  59.             else if (file type obsolete of i as string) is in File_Type then
  60.                 --and (size of i) > (250000) then --こうやってサイズを制限することも可能
  61.                 
  62.                 --ここでアクションしてまんねん
  63.                 tell application "Adobe Photoshop(R) 4.0.1J"
  64.                     open file (i as string)
  65.                     do script Action_name
  66.                 end tell
  67.                 set AA to AA + 1
  68.                 
  69.             else
  70.                 --display dialog (name of i as string) & "は処理できません"
  71.                 set BB to BB + 1
  72.             end if
  73.             try
  74.             on error errMsg number ERRNO --エラー処理
  75.                 if ERRNO is -1728 then --クリエータが特定できない
  76.                     display dialog (name of i as string) & "は処理できません" & return & errMsg & ERRNO
  77.                 else --それ以外の不意打ちには
  78.                     display dialog "エラーが起きました" & return & errMsg & ERRNO
  79.                     exit repeat
  80.                 end if
  81.             end try
  82.             
  83.         end repeat
  84.         
  85.         beep 3
  86.         display dialog (AA as text) & "個のファイルを処理しました" & return & (BB as text) & "個のファイルは未処理です"
  87.         
  88.     end tell
  89. end Action_G
  90.